#!/bin/bash
mkdir backup
cp *rank*.txt backup
mydirs="ex ey ez bx by bz jx jy jz rho"
for ndir in $mydirs
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*$ndir".txt" $ndir
    cp gather.py $ndir
    cd $ndir
    python gather.py
    cd ../
    rm -rvf $ndir
done
mydirl="dens_ele dens_ion ek_ele ek_ion cell_ez dens_pho"
for ndir in $mydirl
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*[0-9]_$ndir*".txt" $ndir
    cp gathers.py $ndir
    cd $ndir
    python gathers.py
    cd ../
    rm -rvf $ndir
done

mydirp="_electron _ion _photon"
for ndir in $mydirp
do
    rm -rvf $ndir
    mkdir $ndir
    mv *rank*[0-9]$ndir".txt" $ndir
    cp gatherp.py $ndir
    cd $ndir
    python gatherp.py
    cd ..
    rm -rvf $ndir
done



mkdir ptcls
mv *[0-9]_ele* ptcls
mv *[0-9]_pho* ptcls
mv *[0-9]_ion* ptcls
